Skip to content

refactor(cli): migrate from citty to commander.js#53

Merged
lollipop-onl merged 16 commits into
mainfrom
feat/commander-migration
Mar 8, 2026
Merged

refactor(cli): migrate from citty to commander.js#53
lollipop-onl merged 16 commits into
mainfrom
feat/commander-migration

Conversation

@lollipop-onl
Copy link
Copy Markdown
Collaborator

Summary

  • Replace citty CLI framework with commander.js across the entire CLI application (~170 files)
  • Add BeeCommand class extending commander's Command with custom examples(), envVars(), addCommands() methods and helpInformation() override
  • Add RequiredOption class with interactive prompting via resolveOptions()
  • Add shared common-options.ts factory functions and centralized error.ts handler
  • Delete legacy command-usage.ts and common-args.ts, remove citty dependency
  • All commands now use export default and parseAsync() patterns
  • resolveOptions() returns void (side-effect only) to avoid unnecessary type assertions

Why

  • Native repeated-flag support (--notify 1 --notify 2) without custom splitArg
  • Reduced custom help rendering code via helpInformation() override
  • Eliminated as never test casts — commander's parseAsync() is naturally typed
  • Smaller, more consistent command definitions

Test plan

  • 122 test files, 668 tests all passing
  • TypeScript typecheck passes
  • Build succeeds
  • No remaining citty imports or references

🤖 Generated with Claude Code

lollipop-onl and others added 10 commits March 8, 2026 18:25
…on-options)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ndency

- Migrate repo, space, document, category, milestone, status,
  notification, and issue-type commands from citty to commander
- Delete legacy command-usage.ts and common-args.ts
- Remove citty dependency
- Change resolveOptions to void (side-effect only) to avoid
  unnecessary type assertions on opts
- Remove all redundant `as` casts from command files
- Fix Option naming conflict in issue/list.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused BacklogOption import from issue/list.ts
- Simplify nested ternary in api.ts to typeof check

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 8, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 91.6% 1812 / 1978
🔵 Statements 91.62% 1881 / 2053
🔵 Functions 90.32% 392 / 434
🔵 Branches 74.26% 811 / 1092
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/cli/src/commands/api.ts 48% 20% 57.14% 48% 111-118, 123-127, 131-135, 145-155, 172-181
apps/cli/src/commands/browse.ts 87.5% 75% 100% 87.5% 82
apps/cli/src/commands/completion.ts 100% 100% 100% 100%
apps/cli/src/commands/dashboard.ts 100% 83.33% 100% 100%
apps/cli/src/commands/auth/login.ts 100% 75% 100% 100%
apps/cli/src/commands/auth/logout.ts 68.18% 50% 33.33% 71.42% 6, 42-53
apps/cli/src/commands/auth/refresh.ts 100% 90% 100% 100%
apps/cli/src/commands/auth/status.ts 100% 100% 100% 100%
apps/cli/src/commands/auth/switch.ts 50% 28.57% 40% 52.63% 6, 39-56, 64
apps/cli/src/commands/auth/token.ts 100% 83.33% 100% 100%
apps/cli/src/commands/category/create.ts 100% 100% 100% 100%
apps/cli/src/commands/category/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/category/edit.ts 100% 100% 100% 100%
apps/cli/src/commands/category/list.ts 100% 100% 100% 100%
apps/cli/src/commands/document/attachments.ts 100% 75% 100% 100%
apps/cli/src/commands/document/create.ts 100% 100% 100% 100%
apps/cli/src/commands/document/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/document/list.ts 100% 90% 100% 100%
apps/cli/src/commands/document/tree.ts 100% 91.66% 100% 100%
apps/cli/src/commands/document/view.ts 100% 75% 100% 100%
apps/cli/src/commands/issue/attachments.ts 100% 75% 100% 100%
apps/cli/src/commands/issue/close.ts 100% 66.66% 100% 100%
apps/cli/src/commands/issue/comment.ts 100% 95.83% 100% 100%
apps/cli/src/commands/issue/count.ts 94.11% 62.5% 100% 94.11% 21
apps/cli/src/commands/issue/create.ts 100% 64.28% 100% 100%
apps/cli/src/commands/issue/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/issue/edit.ts 100% 63.63% 100% 100%
apps/cli/src/commands/issue/list.ts 77.27% 62.5% 71.42% 76.19% 16-21
apps/cli/src/commands/issue/reopen.ts 100% 50% 100% 100%
apps/cli/src/commands/issue/status.ts 100% 100% 100% 100%
apps/cli/src/commands/issue/view.ts 87.5% 65.62% 57.14% 87.5% 60-69, 90
apps/cli/src/commands/issue-type/create.ts 100% 100% 100% 100%
apps/cli/src/commands/issue-type/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/issue-type/edit.ts 100% 100% 100% 100%
apps/cli/src/commands/issue-type/list.ts 100% 100% 100% 100%
apps/cli/src/commands/milestone/create.ts 100% 100% 100% 100%
apps/cli/src/commands/milestone/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/milestone/edit.ts 100% 100% 100% 100%
apps/cli/src/commands/milestone/list.ts 100% 100% 100% 100%
apps/cli/src/commands/notification/count.ts 100% 100% 100% 100%
apps/cli/src/commands/notification/list.ts 100% 81.25% 100% 100%
apps/cli/src/commands/notification/read-all.ts 100% 100% 100% 100%
apps/cli/src/commands/notification/read.ts 100% 100% 100% 100%
apps/cli/src/commands/pr/comment.ts 100% 90% 100% 100%
apps/cli/src/commands/pr/comments.ts 100% 66.66% 100% 100%
apps/cli/src/commands/pr/count.ts 94.44% 64.28% 80% 94.44% 48
apps/cli/src/commands/pr/create.ts 100% 75% 100% 100%
apps/cli/src/commands/pr/edit.ts 92.85% 75% 100% 92.85% 54
apps/cli/src/commands/pr/list.ts 100% 72.72% 100% 100%
apps/cli/src/commands/pr/status.ts 100% 83.33% 100% 100%
apps/cli/src/commands/pr/view.ts 100% 68.75% 100% 100%
apps/cli/src/commands/project/activities.ts 82.6% 53.84% 80% 81.81% 18, 24-25, 32
apps/cli/src/commands/project/add-user.ts 100% 75% 100% 100%
apps/cli/src/commands/project/create.ts 100% 87.5% 100% 100%
apps/cli/src/commands/project/delete.ts 100% 75% 100% 100%
apps/cli/src/commands/project/edit.ts 100% 50% 100% 100%
apps/cli/src/commands/project/list.ts 100% 83.33% 100% 100%
apps/cli/src/commands/project/remove-user.ts 100% 75% 100% 100%
apps/cli/src/commands/project/users.ts 100% 62.5% 100% 100%
apps/cli/src/commands/project/view.ts 100% 63.63% 100% 100%
apps/cli/src/commands/repo/clone.ts 100% 100% 80% 100%
apps/cli/src/commands/repo/list.ts 100% 66.66% 100% 100%
apps/cli/src/commands/repo/view.ts 100% 75% 100% 100%
apps/cli/src/commands/space/activities.ts 81.81% 53.57% 80% 80.95% 18, 24-25, 32
apps/cli/src/commands/space/disk-usage.ts 100% 100% 100% 100%
apps/cli/src/commands/space/info.ts 100% 50% 100% 100%
apps/cli/src/commands/space/notification.ts 100% 75% 100% 100%
apps/cli/src/commands/star/add.ts 100% 92.85% 100% 100%
apps/cli/src/commands/star/count.ts 100% 100% 100% 100%
apps/cli/src/commands/star/list.ts 100% 100% 100% 100%
apps/cli/src/commands/star/remove.ts 100% 100% 100% 100%
apps/cli/src/commands/status/create.ts 100% 100% 100% 100%
apps/cli/src/commands/status/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/status/edit.ts 100% 100% 100% 100%
apps/cli/src/commands/status/list.ts 100% 100% 100% 100%
apps/cli/src/commands/team/create.ts 100% 100% 100% 100%
apps/cli/src/commands/team/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/team/edit.ts 100% 100% 100% 100%
apps/cli/src/commands/team/list.ts 100% 100% 100% 100%
apps/cli/src/commands/team/view.ts 100% 66.66% 100% 100%
apps/cli/src/commands/user/activities.ts 81.81% 53.57% 80% 80.95% 18, 24-25, 32
apps/cli/src/commands/user/list.ts 100% 66.66% 100% 100%
apps/cli/src/commands/user/me.ts 100% 50% 100% 100%
apps/cli/src/commands/user/view.ts 100% 50% 100% 100%
apps/cli/src/commands/watching/add.ts 100% 100% 100% 100%
apps/cli/src/commands/watching/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/watching/list.ts 100% 100% 100% 100%
apps/cli/src/commands/watching/read.ts 100% 100% 100% 100%
apps/cli/src/commands/watching/view.ts 100% 50% 100% 100%
apps/cli/src/commands/webhook/create.ts 100% 50% 100% 100%
apps/cli/src/commands/webhook/delete.ts 100% 75% 100% 100%
apps/cli/src/commands/webhook/edit.ts 100% 50% 100% 100%
apps/cli/src/commands/webhook/list.ts 100% 83.33% 100% 100%
apps/cli/src/commands/webhook/view.ts 100% 50% 100% 100%
apps/cli/src/commands/wiki/attachments.ts 100% 100% 100% 100%
apps/cli/src/commands/wiki/count.ts 100% 50% 100% 100%
apps/cli/src/commands/wiki/create.ts 100% 100% 100% 100%
apps/cli/src/commands/wiki/delete.ts 100% 100% 100% 100%
apps/cli/src/commands/wiki/edit.ts 100% 100% 100% 100%
apps/cli/src/commands/wiki/history.ts 100% 100% 100% 100%
apps/cli/src/commands/wiki/list.ts 100% 75% 100% 100%
apps/cli/src/commands/wiki/tags.ts 100% 75% 100% 100%
apps/cli/src/commands/wiki/view.ts 100% 87.5% 100% 100%
apps/cli/src/lib/bee-command.ts 100% 83.33% 100% 100%
apps/cli/src/lib/common-options.ts 100% 100% 100% 100%
apps/cli/src/lib/error.ts 0% 0% 0% 0% 6-23
apps/cli/src/lib/required-option.ts 100% 100% 100% 100%
Generated in workflow #273 for commit 70f9338 by the Vitest Coverage Report Action

lollipop-onl and others added 6 commits March 8, 2026 19:00
Commander's addCommands() requires default exports from command modules.
Disable no-default-export rule for apps/cli/src/commands/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Commands like `project view`, `project users`, `project activities`,
`project delete`, `project edit`, `repo list`, `wiki list`, `wiki count`,
and `wiki tags` should accept project as a positional argument per the
documented CLI interface, not as a --project/-p option.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…line completions

- Use resolveUserId for @me in issue list, issue count, issue edit,
  and pr list commands (previously passed NaN to API)
- Unify user activities --activity-type to comma-separated format,
  matching space and project activities commands
- Inline shell completion scripts as string literals so they work
  in the bundled dist output (previously failed with ENOENT)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ble options

Replace splitArg/split(",") patterns with commander's native argParser
for repeatable options. This is the idiomatic commander.js approach:
  --activity-type 1 --activity-type 2  (instead of --activity-type 1,2)
  --status open --status merged        (instead of --status open,merged)

Also replace `as number[]` with `satisfies number[]` throughout, and
add @me support to pr count command's assignee option.

Note: -p/--project with .env("BACKLOG_PROJECT") retains comma-separated
parsing since env vars provide a single string value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…type cast

- Remove completions/bash.sh, zsh.zsh, fish.fish (now inlined in completion.ts)
- Remove `as { json?: string }` cast in dashboard.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lollipop-onl lollipop-onl merged commit 9855a47 into main Mar 8, 2026
7 checks passed
@lollipop-onl lollipop-onl deleted the feat/commander-migration branch March 8, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant